import { defineConfig } from 'vite'
import { resolve } from 'path'
import { visualizer } from 'rollup-plugin-visualizer'

// https://vitejs.dev/config/
export default defineConfig({
  
  plugins: [
    visualizer({
      emitFile: false,
      filename: 'stats.html',
      open: true
    })
  ],
  resolve: {
    alias: [{
      find: '@',
      replacement: resolve(__dirname, 'src'),
    }, ],
  },
  base:'https://lanke.cc/',
  build: {
    rollupOptions: {
      output: {
        entryFileNames:'assets/[name].js',
        chunkFileNames :'assets/[name].js',
        assetFileNames:'assets/[name].[ext]',
        manualChunks(id) {
          console.log('----build----:',id)
          // if (id.includes('node_modules')) {
          //   return 'vendor'
          // }
          if (id.includes('node_modules') || id.includes('/src/js/')) {
            return 'ani_js'
          }
        }
      }
    },
    target: 'es2015',
    minify: 'terser',
    terserOptions: {
      compress: {
        // 生产环境去除console
        drop_console: true,
      },
    }
  },
  server: {
    host: '0.0.0.0'
  }
})